package com.ts.api.module.match.plan.model;

import com.ts.api.common.constant.product.ProductPlanTypeEnum;
import com.ts.api.module.match.plan.config.PlanMatchConfig;
import com.ts.api.module.match.plan.internal.core.PlanMatchChannelType;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 *  渠道匹配实体
 *
 *  @see ApiPlanMatch
 *  @see ChannelPlanMatch
 *  @see ApiWakePlanMatch
 *  @author Pan
 */
@Data
public abstract class AbstractPlanMatch {

    /** 渠道id（API/自有渠道都自带) */
    private Long loanChannelId;
    /** 计划匹配渠道类型枚举 */
    private PlanMatchChannelType planMatchChannelType;
    /** 匹配城市计划类型 */
    private List<ProductPlanTypeEnum> listPlanType;
    /** 计划匹配配置类 */
    private PlanMatchConfig planMatchConfig;
    /** 超时时间 */
    private Integer httpTimeout;
    /** 当前渠道价 */
    private BigDecimal channelPrice;
    /** 当前渠道分润比例 */
    private BigDecimal channelShareRatio;
    /** 是否开启多推 */
    private Boolean enableMultiPush = false;

    /**
     *  默认构造函数
     */
    protected AbstractPlanMatch() {
        this(new PlanMatchConfig());
    }

    /**
     *  自定义配置构造函数
     *
     *  @param config   计划匹配配置
     */
    protected AbstractPlanMatch(PlanMatchConfig config) {
        this.planMatchConfig = config;
    }

    public boolean hasApiChannel() {
        return PlanMatchChannelType.API.equals(this.getPlanMatchChannelType());
    }

    public boolean hasChannel() {
        return PlanMatchChannelType.CHANNEL.equals(this.getPlanMatchChannelType());
    }
}
